<template>
	<view class="content">
		<view v-for="(item,index) in orderList" :key="index" class="order-item" @click="godetail(item)">
			<view class="i-top b-b">
				<text class="time">订单号:{{item.orderno}}</text>
				<text class="state" :style="{color: item.stateTipColor}">{{item.stateTip}}</text>
		
			</view>
 
			<view class="goods-box-single">
				<image class="goods-img" :src="item.productinfo.product_image" mode="aspectFill"></image>
				<view class="right">
					<text class="title clamp">{{item.productinfo.product_title}}</text>
					<text class="attr-box">{{item.productinfo.specvalue_text}} </text>
					<text class="price">{{item.productinfo.total_productprice}}</text>
				</view>
			</view>

		</view>
		
		<uni-load-more :status="loadingType"></uni-load-more>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderList:[],
				page:1,
				pagesize:6,
				loadingType: 'more',
					
			}
		},
		onLoad(option) {
			this.getList();
		},
		methods: {
			getList()
			{
				let that = this;
				let param={
					page:this.page
				};
				this.$util.req("/orderservice/getList",param,true,function(res){
					console.log("-res---");
					console.log(res);
					res.data.forEach(item=>{
						let {stateTip,stateTipColor} = that.orderStateExp(item.status);
						item.stateTip = stateTip;
						item.stateTipColor = stateTipColor;
						that.orderList.push(item);
					});
				
					that.loadingType = res.data.length < that.pagesize ? 'nomore' : 'more';
					that.page +=1;
				});
			},
			godetail(item)
			{
				this.$util.navigate("/pages/order/serviceinfo?id="+item.id,true);
			},
			//订单状态文字和颜色
			orderStateExp(pay_status, trans_status, status) {
				let stateTip = '',
					stateTipColor = '#fa436a';
					//服务状态:0=待处理,1=处理中,2=已处理
				if (status == "2") {
					stateTip = "已处理";
					stateTipColor = '#909399';
				} else if(status=="0"){
					stateTip = "待处理";
				}else{
					stateTip = "处理中";
				}
			
			 
				return {
					stateTip,
					stateTipColor
				};
			}
		}
	}
</script>

<style lang="scss">
	page,
	.content {
		background: $page-color-base;
		height: 100%;
	}
	.order-item {
		display: flex;
		flex-direction: column;
		padding-left: 30upx;
		background: #fff;
		margin-top: 16upx;

		.i-top {
			display: flex;
			align-items: center;
			height: 80upx;
			padding-right: 30upx;
			font-size: $font-base;
			color: $font-color-dark;
			position: relative;

			.time {
				flex: 1;
			}

			.state {
				color: $base-color;
			}

			.del-btn {
				padding: 10upx 0 10upx 36upx;
				font-size: $font-lg;
				color: $font-color-light;
				position: relative;

				&:after {
					content: '';
					width: 0;
					height: 30upx;
					border-left: 1px solid $border-color-dark;
					position: absolute;
					left: 20upx;
					top: 50%;
					transform: translateY(-50%);
				}
			}
		}

		/* 多条商品 */
		.goods-box {
			height: 160upx;
			padding: 20upx 0;
			white-space: nowrap;

			.goods-item {
				width: 120upx;
				height: 120upx;
				display: inline-block;
				margin-right: 24upx;
			}

			.goods-img {
				display: block;
				width: 100%;
				height: 100%;
			}
		}

		/* 单条商品 */
		.goods-box-single {
			display: flex;
			padding: 20upx 0;

			.goods-img {
				display: block;
				width: 120upx;
				height: 120upx;
			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				padding: 0 30upx 0 24upx;
				overflow: hidden;

				.title {
					font-size: $font-base + 2upx;
					color: $font-color-dark;
					line-height: 1;
				}

				.attr-box {
					font-size: $font-sm + 2upx;
					color: $font-color-light;
					padding: 10upx 12upx;
				}

				.price {
					font-size: $font-base + 2upx;
					color: $font-color-dark;

					&:before {
						content: '￥';
						font-size: $font-sm;
						margin: 0 2upx 0 8upx;
					}
				}
			}
		}

		.price-box {
			display: flex;
			justify-content: flex-end;
			align-items: baseline;
			padding: 20upx 30upx;
			font-size: $font-sm + 2upx;
			color: $font-color-light;

			.num {
				margin: 0 8upx;
				color: $font-color-dark;
			}

			.price {
				font-size: $font-lg;
				color: $font-color-dark;

				&:before {
					content: '￥';
					font-size: $font-sm;
					margin: 0 2upx 0 8upx;
				}
			}
		}

		.action-box {
			display: flex;
			justify-content: flex-end;
			align-items: center;
			height: 100upx;
			position: relative;
			padding-right: 30upx;
		}

		.action-btn {
			width: 160upx;
			height: 60upx;
			margin: 0;
			margin-left: 24upx;
			padding: 0;
			text-align: center;
			line-height: 60upx;
			font-size: $font-sm + 2upx;
			color: $font-color-dark;
			background: #fff;
			border-radius: 100px;

			&:after {
				border-radius: 100px;
			}

			&.recom {
				background: #fff9f9;
				color: $base-color;

				&:after {
					border-color: #f7bcc8;
				}
			}
		}
	}

</style>
